#!/user/bin/env python3
# -*- coding: utf-8 -*-
# author:YaFans

#随机生成20个[1, 20]的正整数，统计每个数字出现的次数，排序并降序输出次数最多的前三个数字及次数

import random


lst = random.choices(list(range(1,21)),k=20)
d = {i:lst.count(i) for i in lst}

#d = {}
# for i in lst:
#     if not d.get(i):
#         d[i] = 1
#     else:
#         d[i] += 1
#
#
result = sorted(d.items(), key=lambda item:item[1],reverse=True)

for k,v in result[:3]:
    print('{}出现{}次'.format(k,v))


